package com.wnzt.baszh.core.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletWebRequest;

/**
 * 获取当前会话
 * 
 * @version [版本�? 2013-7-9 下午3:57:28]
 */
public class RequestContextHolderUtils {

    /**
     * 
     * 获取当前request对象
     * 
     * @return [参数说明]
     * @return HttpServletRequest [返回类型说明]
     */
    public static HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
    }

    /**
     * 
     * 获取当前response对象
     * 
     * @return [参数说明]
     * @return HttpServletResponse [返回类型说明]
     */
    public static HttpServletResponse getResponse() {
        return ((ServletWebRequest) RequestContextHolder.currentRequestAttributes()).getResponse();
    }

    /**
     * 获取当前session对象
     * 
     * @return [参数说明]
     * @return HttpSession [返回类型说明]
     */
    public static HttpSession getSession() {
        return getRequest().getSession();
    }
}
